package com.wsx.rpc.rtp;

import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.Player;
import javax.media.control.BufferControl;
import javax.media.rtp.RTPManager;
import javax.media.rtp.ReceiveStreamListener;
import javax.media.rtp.SessionAddress;
import javax.media.rtp.SessionListener;
import javax.media.rtp.event.ReceiveStreamEvent;
import javax.media.rtp.event.SessionEvent;

/**
 * @author wangshuaixin
 * @Title: com.wsx.rpc.rtp.Receiver
 * @Description: TODO
 * @date 2018/11/28
 */
public class Receiver implements ReceiveStreamListener,ControllerListener,SessionListener {

    Player player;
    RTPManager rtpManager;

    public Receiver(SessionAddress local, SessionAddress target) {
        rtpManager = RTPManager.newInstance();
        rtpManager.addReceiveStreamListener(this);

        try {
            rtpManager.initialize(local);
            rtpManager.addTarget(target);
        } catch (Exception e) {
            e.printStackTrace();
        }

        BufferControl bc = (BufferControl)rtpManager.getControl("javax.media.control.BufferControl");
        if (null != bc) {
            bc.setBufferLength(350);
            //断开连接的操作
        }

    }

    @Override
    public void controllerUpdate(ControllerEvent controllerEvent) {

    }

    @Override
    public void update(ReceiveStreamEvent receiveStreamEvent) {

    }

    @Override
    public void update(SessionEvent sessionEvent) {

    }
}
